package com.snj.wef.selfwedding;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.snj.lib.PartnerHolder;
import com.snj.lib.RankingHolder;
import com.snj.lib.WefmallHolder;
import com.snj.wef.R;


public class PartnerAdapter extends BaseAdapter {
	
	String tag = "PartnerAdapter";
	
	Context context;
	int layout;
	
	
	ArrayList<PartnerItem> mPartnerList;
	
	LayoutInflater mInflater = null;
	
	
	public PartnerAdapter(Context _context, int _layout, ArrayList<PartnerItem> _plist) {
		// TODO Auto-generated constructor stub
		
		this.context = _context;
		this.layout = _layout;
		this.mPartnerList = _plist;
		
	}
	
	public void Insert(ArrayList<PartnerItem> mList)
	{
		mPartnerList.addAll(mList);
	}
	
	public void SetList(ArrayList<PartnerItem> mList)
	{
		mPartnerList = mList;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return mPartnerList.size();
	}

	public PartnerItem getItem(int position) {
		// TODO Auto-generated method stub
		return mPartnerList.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	
		PartnerHolder holder = null;
		
		if(convertView == null)
		{
			mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(layout, parent, false);
			
			holder = new PartnerHolder();
			
			holder.img_partner = (ImageView)convertView.findViewById(R.id.img_partnerimg);
			holder.txt_partner = (TextView)convertView.findViewById(R.id.txt_partername);
			
			convertView.setTag(holder);
		}
		else
		{
			holder = (PartnerHolder)convertView.getTag();
		}
		
		
		
		holder.img_partner.setImageBitmap(mPartnerList.get(position).GetPartnerImage());
		holder.txt_partner.setText(mPartnerList.get(position).GetPartnerName());
		
		
		return convertView;
	}
	
	
}
